#include <iostream>
#include <glog/logging.h>

int main(int argc, char** argv) {
    // 初始化 glog
    google::InitGoogleLogging("");

    // 设置日志输出到标准错误
    //FLAGS_logtostderr = true;

    FLAGS_alsologtostderr = true;  // 日志同时输出到 stderr 和文件

    FLAGS_minloglevel = google::GLOG_WARNING;  // 只记录 WARNING 及以上级别

        // 设置日志输出目录
    std::string log_path = "./my_log";
    google::SetLogDestination(google::INFO, (log_path).c_str());
    google::SetLogDestination(google::WARNING, (log_path).c_str());
    google::SetLogDestination(google::ERROR, (log_path).c_str());
    google::SetLogDestination(google::FATAL, (log_path).c_str());

    // 添加日志文件扩展名
    google::SetLogFilenameExtension(".log");
    // 记录不同级别的日志
    LOG(INFO) << "Hello, GOOGLE! This is an info message.";
    LOG(WARNING) << "This is a warning message.";
    LOG(ERROR) << "This is an error message.";
    //LOG(FATAL) << "This is a fatal message.";

    return 0;
}